package api

import (
	"api/basic/config"
	__ "api/basic/proto"
	"api/handler/request"
	"github.com/gin-gonic/gin"
	"net/http"
)

func VideoList(c *gin.Context) {
	var form request.VideoList
	// 根据 Content-Type Header 推断使用哪个绑定器。
	if err := c.ShouldBind(&form); err != nil {
		c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
		return
	}

	list, err := config.Client.VideoList(c, &__.VideoListReq{})
	if err != nil {
		c.JSON(http.StatusOK, gin.H{
			"code": 400,
			"msg":  "查询失败",
			"data": nil,
		})
		return
	} else {
		c.JSON(http.StatusOK, gin.H{
			"code": 200,
			"msg":  "查询成功",
			"data": list,
		})
	}
}
